<template>
	<view class="identity">
		<view class="identity-item">
			<button @click="selectId('1626e8bbdb94093379a240c2154d236d')" :class="{'identity-active': cardType === '1626e8bbdb94093379a240c2154d236d'}" type="default">公民身份</button>
			<button @click="selectId('a58eaa6008385e95fc673667c0ac0053')" :class="{'identity-active': cardType === 'a58eaa6008385e95fc673667c0ac0053'}" type="default">现役军人</button>
			<button @click="selectId('fb4318dc6a5f5b71eaed5a96f3ce645a')" :class="{'identity-active': cardType === 'fb4318dc6a5f5b71eaed5a96f3ce645a'}" type="default">军属身份</button>
		</view>
		<button class="identity-button"type="primary" @click="submit">成功</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cardType: "1626e8bbdb94093379a240c2154d236d",
				level:'A',
				state:'1'
				
			}
		},
		methods: {
			selectId(cardType) {
				this.cardType = cardType
			},
			submit(){
				let that = this
				let vtoken = uni.getStorageSync('vtoken');
				let id = uni.getStorageSync('id');
				// console.log(vtoken);
				that.$api.successStatus({
					 id:id,
					 token:vtoken
					// identity:this.identity 
				}).then(value => {
					// let idcard = value.idcard
					// let  name = value.result.idcard_ocr_result.name
					// console.log(value);
					
					that.$api.cardNumber({
						// 用户id
						id:id,
						// 身份类型
						cardType:this.cardType, 
						// 用户等级
						level:this.level,  //A B C
						// 状态
						state:this.state//1启用  2停用
					}).then(value =>{
						// console.log("55555",value)
						 let idcard =value.cardNumber
						uni.navigateTo({
							 // url:'/pages/index/index?pageStatus=1'
							url:'/pages/index/index?pageStatus=1&idcard=' + idcard
						})
					})
				})
				//假装成功
				// let idcard = 1234567
				// 	uni.navigateTo({
				// 		url:'/pages/index/index?pageStatus=1&idcard=' + idcard
				// 	})
			}
		}
	}
</script>

<style lang="scss">
.identity{
margin: 50rpx 10rpx;
	.identity-item{
		button{
			margin-top: 20rpx;
		}
		.identity-active {
			color: red;
			// margin: 20rpx 10rpx;
		}
	}
	.identity-button{
		width: 90%;
		height: 100rpx;
		line-height: 50rpx;
		border: 1rpx solid #ccc;
		margin: 60rpx auto 0;
		border-radius: 20rpx;
		text-align: center;
		padding: 20rpx 0;
		background: #d5d5ad;
	}
}

</style>
